package com.basswold.nasaesa.client;
/**
 * Forms the basis of different kinds of modules.
 * @author Keith
 *
 */
public abstract class ConstructionModule {
	
	/**
	 * ID number identifies the type of module that this is.
	 */
	protected int ID;
	protected String condition;
	protected String orientation;
	
	/**
	 * The maximum ID numbers for each module type.
	 */
	public static final int plainMaxID = 40;
	public static final int dormMaxID = 80;
	public static final int sanitationMaxID = 100;
	public static final int foodWaterMaxID = 120;
	public static final int gymMaxID = 134;
	public static final int canteenMaxID = 144;
	public static final int powerMaxID = 154;
	public static final int controlMaxID = 164;
	public static final int airlockMaxID = 174;
	public static final int medicalMaxID = 184;
	
	public static enum CardinalDirection {
		NORTH,
		EAST,
		SOUTH,
		WEST
	}
	
	public static enum ModuleType {
		PLAIN,
		DORMITORY,
		SANITATION,
		FOOD_AND_WATER,
		GYM,
		CANTEEN,
		POWER,
		CONTROL,
		AIRLOCK,
		MEDICAL
	}
	
	/**
	 * Constructor.
	 * @param id Identification number of module.
	 */
	ConstructionModule(int id, String cond, String orient) {
		this.ID = id;
		this.condition = cond;
		this.orientation = orient;
	}
	
	public abstract void resetConnections();
	
	/**
	 * Find the specific module type for a module given its ID number.
	 * @param ID Identification number of module to find the type of.
	 * @return The module type.
	 */
	public static ModuleType getType(int ID) {
		if (ID <= plainMaxID) {
			return ModuleType.PLAIN;
		} else if (ID <= dormMaxID) {
			return ModuleType.DORMITORY;
		} else if (ID <= sanitationMaxID) {
			return ModuleType.SANITATION;
		} else if (ID <= foodWaterMaxID) {
			return ModuleType.FOOD_AND_WATER;
		} else if (ID <= gymMaxID) {
			return ModuleType.GYM;
		} else if (ID <= canteenMaxID) {
			return ModuleType.CANTEEN;
		} else if (ID <= powerMaxID) {
			return ModuleType.POWER;
		} else if (ID <= controlMaxID) {
			return ModuleType.CONTROL;
		} else if (ID <= airlockMaxID) {
			return ModuleType.AIRLOCK;
		} else {
			// this must be a medical module
			return ModuleType.MEDICAL;
		}
	}
	
	/**
	 * Return the type of module that this module is.
	 * @return The module type.
	 */
	public ModuleType getType() {
		return this.getType(ID);
	}
}


